declare global {
	interface Math {
		/**
		 * 参数，最小值，最大值
		 * 参数介于最小值与最大值之间时取参数，参数小于最小值取最小值，反之取最大值
		 */
		limit: (v: number, min: number, max: number) => number;
		// return v1 <= num < v2;
		randomInt: (v1: number, v2: number) => number;
		// random_zf(10) => v in [-10,10]
		randomZF: (v: number) => number;
	}
}

export function extendMath(): void {
	// console.log("extend math");
	Math.limit = (v: number, min: number, max: number): number => {
		if (v < min) return min;
		if (v > max) return max;
		return v;
	};
	Math.randomInt = (v1: number, v2: number): number => Math.floor(v1 + Math.random() * (v2 - v1));
	Math.randomZF = (v: number): number => Math.randomInt(-v, v + 1);
}
